import re

import AudioLocation

number_map = {
    "零": 0,
    "一": 1,
    "二": 2,
    "三": 3,
    "四": 4,
    "五": 5,
    "六": 6,
    "七": 7,
    "八": 8,
    "九": 9,
    "十": 10,
    "十一": 11,
    "十二": 12,
    "十三": 13,
    "十四": 14,
    "十五": 15
}


def transform(input):
    if input in number_map:
        num = number_map[input]
    else:
        raise ValueError(f"{input} 不在转化范围内")
    return num


def match(input):
    line = re.sub(r'行.*$', "", input)
    line = transform(line)
    row = input[input.find('行') + 1:]
    row = re.sub(r'列.*$', "", row)
    row = transform(row)
    return line, row


if __name__ == '__main__':
    input = AudioLocation.getLocation()
    # input = '五行四列'
    print(input)
    output = match(input)
    print(output[0])
    print(output[1])
    # return line, row